* handle returned must be used to unmap the frame. This is needed to
* drop the ref count on the frame.
*/
-static u16 pending_grant_handles[MMAP_PAGES];
+static grant_handle_t pending_grant_handles[MMAP_PAGES];
#define pending_handle(_idx, _i) \
(pending_grant_handles[((_idx) * BLKIF_MAX_SEGMENTS_PER_REQUEST) + (_i)])
-#define BLKBACK_INVALID_HANDLE (0xFFFF)
+#define BLKBACK_INVALID_HANDLE (~0)
#ifdef CONFIG_XEN_BLKDEV_TAP_BE
/*
{
struct gnttab_unmap_grant_ref unmap[BLKIF_MAX_SEGMENTS_PER_REQUEST];
unsigned int i, invcount = 0;
- u16 handle;
+ grant_handle_t handle;
int ret;
for (i = 0; i < nr_pages; i++) {
BUG_ON(ret);
for (i = 0; i < nseg; i++) {
- if (likely(map[i].handle >= 0)) {
+ if (likely(map[i].status == 0)) {
pending_handle(pending_idx, i) = map[i].handle;
#ifdef __ia64__
MMAP_VADDR(pending_idx,i) = gnttab_map_vaddr(map[i]);
struct work_struct free_work;
- u16 shmem_handle;
- grant_ref_t shmem_ref;
+ grant_handle_t shmem_handle;
+ grant_ref_t shmem_ref;
} blkif_t;
blkif_t *alloc_blkif(domid_t domid);
unlock_vm_area(blkif->blk_ring_area);
BUG_ON(ret);
- if (op.handle < 0) {
+ if (op.status) {
DPRINTK(" Grant table operation failure !\n");
- return op.handle;
+ return op.status;
}
blkif->shmem_ref = shared_page;
*/
struct grant_handle_pair
{
- u16 kernel;
- u16 user;
+ grant_handle_t kernel;
+ grant_handle_t user;
};
static struct grant_handle_pair pending_grant_handles[MMAP_PAGES];
#define pending_handle(_idx, _i) \
uvaddr = MMAP_VADDR(user_vstart, pending_idx, i/2);
kvaddr = MMAP_VADDR(mmap_vstart, pending_idx, i/2);
- if (unlikely(map[i].handle < 0)) {
+ if (unlikely(map[i].status)) {
DPRINTK("Error on kernel grant mapping (%d)\n",
- map[i].handle);
- ret = map[i].handle;
+ map[i].status);
+ ret = map[i].status;
cancel = 1;
}
- if (unlikely(map[i+1].handle < 0)) {
+ if (unlikely(map[i+1].status)) {
DPRINTK("Error on user grant mapping (%d)\n",
- map[i+1].handle);
- ret = map[i+1].handle;
+ map[i+1].status);
+ ret = map[i+1].status;
cancel = 1;
}
struct work_struct free_work;
- u16 shmem_handle;
+ grant_handle_t shmem_handle;
grant_ref_t shmem_ref;
} blkif_t;
unlock_vm_area(blkif->blk_ring_area);
BUG_ON(ret);
- if (op.handle < 0) {
+ if (op.status) {
DPRINTK(" Grant table operation failure !\n");
- return op.handle;
+ return op.status;
}
blkif->shmem_ref = shared_page;
u8 fe_dev_addr[6];
/* Physical parameters of the comms window. */
- u16 tx_shmem_handle;
+ grant_handle_t tx_shmem_handle;
grant_ref_t tx_shmem_ref;
- u16 rx_shmem_handle;
+ grant_handle_t rx_shmem_handle;
grant_ref_t rx_shmem_ref;
unsigned int evtchn;
unsigned int irq;
unlock_vm_area(netif->comms_area);
BUG_ON(ret);
- if (op.handle < 0) {
+ if (op.status) {
DPRINTK(" Gnttab failure mapping tx_ring_ref!\n");
- return op.handle;
+ return op.status;
}
netif->tx_shmem_ref = tx_ring_ref;
unlock_vm_area(netif->comms_area);
BUG_ON(ret);
- if (op.handle < 0) {
+ if (op.status) {
DPRINTK(" Gnttab failure mapping rx_ring_ref!\n");
- return op.handle;
+ return op.status;
}
netif->rx_shmem_ref = rx_ring_ref;
static struct sk_buff_head tx_queue;
-static u16 grant_tx_ref[MAX_PENDING_REQS];
+static grant_handle_t grant_tx_handle[MAX_PENDING_REQS];
static gnttab_unmap_grant_ref_t tx_unmap_ops[MAX_PENDING_REQS];
static gnttab_map_grant_ref_t tx_map_ops[MAX_PENDING_REQS];
pending_idx = dealloc_ring[MASK_PEND_IDX(dc++)];
gop->host_addr = MMAP_VADDR(pending_idx);
gop->dev_bus_addr = 0;
- gop->handle = grant_tx_ref[pending_idx];
+ gop->handle = grant_tx_handle[pending_idx];
gop++;
}
ret = HYPERVISOR_grant_table_op(
sizeof(txreq));
/* Check the remap error code. */
- if (unlikely(mop->handle < 0)) {
+ if (unlikely(mop->status)) {
printk(KERN_ALERT "#### netback grant fails\n");
make_tx_response(netif, txreq.id, NETIF_RSP_ERROR);
netif_put(netif);
set_phys_to_machine(
__pa(MMAP_VADDR(pending_idx)) >> PAGE_SHIFT,
FOREIGN_FRAME(mop->dev_bus_addr >> PAGE_SHIFT));
- grant_tx_ref[pending_idx] = mop->handle;
+ grant_tx_handle[pending_idx] = mop->handle;
data_len = (txreq.size > PKT_PROT_LEN) ?
PKT_PROT_LEN : txreq.size;
struct work_struct work;
- u16 shmem_handle;
+ grant_handle_t shmem_handle;
grant_ref_t shmem_ref;
} tpmif_t;
unlock_vm_area(tpmif->tx_area);
BUG_ON(ret);
- if (op.handle < 0) {
+ if (op.status) {
DPRINTK(" Grant table operation failure !\n");
- return op.handle;
+ return op.status;
}
tpmif->shmem_ref = shared_page;
* and send it to the front end.
*/
tpmif_t *tpmif = pak->tpmif;
- u16 handle;
+ grant_handle_t handle;
int rc = 0;
unsigned int i = 0;
unsigned int offset = 0;
handle = map_op.handle;
- if (map_op.handle < 0) {
+ if (map_op.status) {
DPRINTK(" Grant table operation failure !\n");
return 0;
}
u32 i = (last_read / PAGE_SIZE);
u32 pg_offset = last_read & (PAGE_SIZE - 1);
u32 to_copy;
- u16 handle;
+ grant_handle_t handle;
tpmif_tx_request_t *tx;
tx = &tpmif->tx->ring[0].req;
BUG();
}
- if (map_op.handle < 0) {
+ if (map_op.status) {
DPRINTK(" Grant table operation failure !\n");
return -EFAULT;
}
int xc_domain_ioport_permission(int xc_handle,
uint32_t domid,
- uint16_t first_port,
- uint16_t nr_ports,
- uint16_t allow_access)
+ uint32_t first_port,
+ uint32_t nr_ports,
+ uint32_t allow_access)
{
DECLARE_DOM0_OP;
int xc_gnttab_map_grant_ref(int xc_handle,
uint64_t host_virt_addr,
uint32_t dom,
- uint16_t ref,
+ grant_ref_t ref,
uint16_t flags,
- int16_t *handle,
+ int16_t *status,
+ grant_handle_t *handle,
uint64_t *dev_bus_addr)
{
struct gnttab_map_grant_ref op;
if ( (rc = do_gnttab_op(xc_handle, GNTTABOP_map_grant_ref,
&op, 1)) == 0 )
{
+ *status = op.status;
*handle = op.handle;
*dev_bus_addr = op.dev_bus_addr;
}
int xc_gnttab_unmap_grant_ref(int xc_handle,
uint64_t host_virt_addr,
uint64_t dev_bus_addr,
- uint16_t handle,
+ grant_handle_t handle,
int16_t *status)
{
struct gnttab_unmap_grant_ref op;
#include <sys/ptrace.h>
#include <xen/xen.h>
#include <xen/dom0_ops.h>
+#include <xen/grant_table.h>
#include <xen/version.h>
#include <xen/event_channel.h>
#include <xen/sched.h>
int xc_domain_ioport_permission(int xc_handle,
uint32_t domid,
- uint16_t first_port,
- uint16_t nr_ports,
- uint16_t allow_access);
+ uint32_t first_port,
+ uint32_t nr_ports,
+ uint32_t allow_access);
unsigned long xc_make_page_below_4G(int xc_handle, uint32_t domid,
unsigned long mfn);
int xc_gnttab_map_grant_ref(int xc_handle,
uint64_t host_virt_addr,
uint32_t dom,
- uint16_t ref,
+ grant_ref_t ref,
uint16_t flags,
- int16_t *handle,
+ int16_t *status,
+ grant_handle_t *handle,
uint64_t *dev_bus_addr);
int xc_gnttab_unmap_grant_ref(int xc_handle,
uint64_t host_virt_addr,
uint64_t dev_bus_addr,
- uint16_t handle,
+ grant_handle_t handle,
int16_t *status);
int xc_gnttab_setup_table(int xc_handle,
(GNTMAP_device_map|GNTMAP_host_map)) == 0) )
{
DPRINTK("Bad ref (%d) or flags (%x).\n", ref, dev_hst_ro_flags);
- (void)__put_user(GNTST_bad_gntref, &uop->handle);
+ (void)__put_user(GNTST_bad_gntref, &uop->status);
return GNTST_bad_gntref;
}
if ( acm_pre_grant_map_ref(dom) )
{
- (void)__put_user(GNTST_permission_denied, &uop->handle);
+ (void)__put_user(GNTST_permission_denied, &uop->status);
return GNTST_permission_denied;
}
if ( rd != NULL )
put_domain(rd);
DPRINTK("Could not find domain %d\n", dom);
- (void)__put_user(GNTST_bad_domain, &uop->handle);
+ (void)__put_user(GNTST_bad_domain, &uop->status);
return GNTST_bad_domain;
}
{
put_domain(rd);
DPRINTK("Maptrack table is at maximum size.\n");
- (void)__put_user(GNTST_no_device_space, &uop->handle);
+ (void)__put_user(GNTST_no_device_space, &uop->status);
return GNTST_no_device_space;
}
{
put_domain(rd);
DPRINTK("No more map handles available.\n");
- (void)__put_user(GNTST_no_device_space, &uop->handle);
+ (void)__put_user(GNTST_no_device_space, &uop->status);
return GNTST_no_device_space;
}
(void)__put_user((u64)frame << PAGE_SHIFT, &uop->dev_bus_addr);
(void)__put_user(handle, &uop->handle);
+ (void)__put_user(GNTST_okay, &uop->status);
put_domain(rd);
return rc;
unlock_out:
spin_unlock(&rd->grant_table->lock);
- (void)__put_user(rc, &uop->handle);
+ (void)__put_user(rc, &uop->status);
put_maptrack_handle(ld->grant_table, handle);
return rc;
}
{
domid_t dom;
grant_ref_t ref;
- u16 handle;
+ grant_handle_t handle;
struct domain *ld, *rd;
active_grant_entry_t *act;
grant_entry_t *sha;
grant_table_t *gt = d->grant_table;
grant_mapping_t *map;
grant_ref_t ref;
- u16 handle;
+ grant_handle_t handle;
struct domain *rd;
active_grant_entry_t *act;
grant_entry_t *sha;
* This makes sure that old versions of dom0 tools will stop working in a
* well-defined way (rather than crashing the machine, for instance).
*/
-#define DOM0_INTERFACE_VERSION 0xAAAA1013
+#define DOM0_INTERFACE_VERSION 0xAAAA1014
/************************************************************************/
*/
typedef uint32_t grant_ref_t;
+/*
+ * Handle to track a mapping created via a grant reference.
+ */
+typedef uint32_t grant_handle_t;
+
/*
* GNTTABOP_map_grant_ref: Map the grant entry (<dom>,<ref>) for access
* by devices and/or host CPUs. If successful, <handle> is a tracking number
typedef struct gnttab_map_grant_ref {
/* IN parameters. */
uint64_t host_addr;
- domid_t dom;
- grant_ref_t ref;
uint32_t flags; /* GNTMAP_* */
+ grant_ref_t ref;
+ domid_t dom;
/* OUT parameters. */
- int32_t handle; /* +ve: handle; -ve: GNTST_* */
+ int16_t status; /* GNTST_* */
+ grant_handle_t handle;
uint64_t dev_bus_addr;
} gnttab_map_grant_ref_t;
/* IN parameters. */
uint64_t host_addr;
uint64_t dev_bus_addr;
- uint32_t handle;
+ grant_handle_t handle;
/* OUT parameters. */
- int32_t status; /* GNTST_* */
+ int16_t status; /* GNTST_* */
} gnttab_unmap_grant_ref_t;
/*
domid_t dom;
uint32_t nr_frames;
/* OUT parameters. */
- int32_t status; /* GNTST_* */
+ int16_t status; /* GNTST_* */
unsigned long *frame_list;
} gnttab_setup_table_t;
/* IN parameters. */
domid_t dom;
/* OUT parameters. */
- int32_t status; /* GNTST_* */
+ int16_t status; /* GNTST_* */
} gnttab_dump_table_t;
/*
domid_t domid;
grant_ref_t ref;
/* OUT parameters. */
- int32_t status;
+ int16_t status;
} gnttab_transfer_t;
/*
typedef struct blkif_response {
uint64_t id; /* copied from request */
uint8_t operation; /* copied from request */
- int32_t status; /* BLKIF_RSP_??? */
+ int16_t status; /* BLKIF_RSP_??? */
} blkif_response_t;
#define BLKIF_RSP_ERROR -1 /* non-specific 'error' */